﻿using System;
using System.Threading.Tasks;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using SuperSocket;

namespace Lawn.AppServer
{
    public class StartUp
    {

        private IConfiguration Configuration;
        public StartUp(IConfiguration configuration)
        {
            this.Configuration = configuration;
        }

        public void ConfigureServices(IServiceCollection services)
        {

            services.AddSingleton<Func<IAppSession, PackageHandlingException<MessagePackageInfo>, ValueTask<bool>>>(ExceptionHandler<MessagePackageInfo>.HandlerError);
            services.Configure<OptionCommandType>(type =>
            {
                type.Types.Add(3,typeof(PubMessageHandler));
                type.Types.Add(4,typeof(SubMessageHandler));
            });
            services.AddCommand();
            services.AddTransient<IMessageAsyncCommand, MessageAsyncCommand>();
            services.AddSingleton<ISessionManager, SessionManager>();
        }
        
    }
}